{{ $ := .root }}
{{ $page := .page }}
{{ $talks_len := len (where $.Site.RegularPages "Type" "talk") }}

<!-- Talks widget -->
<div class="row">
  <div class="col-12 col-lg-4 section-heading">
    <h1>{{ with $page.Title }}{{ . | markdownify }}{{ end }}</h1>
    {{ with $page.Params.subtitle }}<p>{{ . | markdownify }}</p>{{ end }}
    {{ if gt $talks_len $page.Params.count }}
    <p class="view-all">
      <a href="{{ ($.Site.GetPage "section" "talk").RelPermalink }}">
        {{ i18n "more_talks" | markdownify }}
        <i class="fas fa-angle-double-right"></i>
      </a>
    </p>
    {{ end }}
  </div>
  <div class="col-12 col-lg-8">
    {{ with $page.Content }}<p>{{ . | markdownify }}</p>{{ end }}

    {{ $.Scratch.Set "talks" (where $.Site.RegularPages "Type" "talk") }}

    {{/* Exclude talks shown in Featured Talks widget? */}}
    {{ if $page.Params.exclude_featured }}
    {{ $.Scratch.Set "talks" (where ($.Scratch.Get "talks") ".Params.featured" "!=" true) }}
    {{ end }}

    {{ range first $page.Params.count (sort ($.Scratch.Get "talks") ".Params.time_start" "desc") }}
      {{ if eq $page.Params.list_format 1 }}
        {{ partial "talk_li_detailed" . }}
      {{ else if eq $page.Params.list_format 2 }}
        {{ partial "talk_li_stream" . }}
      {{ else }}
        {{ partial "talk_li_simple" . }}
      {{ end }}
    {{ end }}
  </div>
</div>
